<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<%  
   if (request.getSession().getAttribute("Login") != null) 
   {
    String message = (String) request.getSession().getAttribute("Login");
    if (!message.equals("true"))
    {
     //如果登录标志不为true则跳转回登录页面
     response.sendRedirect("index.jsp");
    }
    else{
    	request.getSession().setAttribute("Login","true");
    }   
   }
   else
   {
    	response.sendRedirect("index.jsp");
   }
  %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>新闻详情</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="ch-cn">

<style type="text/css">
<!--
body {
	background-image: url();
	background-color: #2E77ED;
}
.STYLE1 {color: #33F2E9}
.STYLE2 {color: #000000}
-->
</style>
</head>

<body onLoad="check()">
	<div align="center">
		<img src="<%=request.getContextPath()%>/PIC/top.jpg" width="820"
			height="115">
	</div>
	<div align="center">
	  <div align="left"></div>
			<p>&nbsp;</p>
			<table width="534" border="0" align="center">
              <tr>
                <td width="217"><div align="center"><a href="AddNewsMain.jsp">添加新闻</a> <br>
                </div></td>
                <td width="307"><div align="center"><a href="ShowNews?method=view">查看新闻 </a> </div></td>
              </tr>
            </table>
			<div align="center">
			  <form action="updateNewsServlet" method="post" enctype="multipart/form-data"  name="newsDetailForm"  size=100>
					<table width="803" height="142" border="1">
						<c:forEach items="${detailsModel.list}" var="news">
							<tr>
							  <th width="210" bgcolor="#33F2E9" scope="row"><span class="STYLE2">新闻类型：</span></th>
							  <td width="577" bgcolor="#33F2E9"><span class="STYLE1">
							    <select name="category" id="category">
							      <option value="1">焦点</option>
							      <option value="2">通知</option>
								  <option value="3">学校</option>
								  <option value="4">国内</option>
								  <option value="5">国际</option>
								  <option value="6">科技</option>
								  <option value="7">体育</option>
								  <option value="8">文艺</option>
								  <option value="9">社团</option>
								  <option value="10">就业</option>
						        </select>
                              <script language="javascript"> 
								for(var i=0;i<document.getElementById("category").options.length;i++)
								{ 
									if(document.getElementById("category").options[i].value=='${news.cid}')
									{ 
										document.getElementById("category").options[i].selected=true; 
									} 
								} 
							    </script>  
							                              
				              <input  type="hidden" name="nid"  id="nid" value="${news.nid}">  
				              </span></tr>

							<tr>
								<th bgcolor="#33F2E9" scope="row"><span class="STYLE2">新闻标题：</span></th>
								<td bgcolor="#33F2E9"><input
									name="newsTitle" type="text" value="${news.title}" size="80" maxlength="300"></td>
							</tr>
							<tr>
								<th bgcolor="#33F2E9" scope="row">新闻摘要:</th>

								<td bgcolor="#33F2E9"><textarea wrap="soft" cols="80" rows="4" name="digest">${news.digest}</textarea></td>
							</tr>
							<tr>
								<th bgcolor="#33F2E9" scope="row">新闻内容:</th>
								<td bgcolor="#33F2E9"><textarea wrap="soft" rows="25" cols="80"
										name="newsDetail" id=""newsDetail">${news.body}</textarea></td>
							</tr>
							<tr>
								<th bgcolor="#33F2E9" scope="row">新闻来源：</th>
							  <td bgcolor="#33F2E9"><select name="source" id ="source" >
                                    <option value="校党委">校党委</option>
                                    <option selected value="校团委">校团委</option>
                                    <option value="校宣传部">校宣传部</option>
                                    <option value="校学生会">校学生会</option>
                                    <option value="理学院团总支">理学院团总支</option>
                                  </select>
								  <script language="javascript"> 
								for(var i=0;i<document.getElementById("source").options.length;i++)
								{ 
									if(document.getElementById("source").options[i].value=="${news.source}")
									{ 
										document.getElementById("source").options[i].selected=true; 
									} 
								}
							</script>	</td>
							</tr>
							<tr>
							  <th bgcolor="#33F2E9" scope="row">新闻图片：</th>
							  <td bgcolor="#33F2E9"><input name="imgrc" type="file" id="imgrc" size="50" maxlength="200">
							  (无需更改不上传)</td>
						  </tr>
							
							<tr>
								<th bgcolor="#33F2E9" scope="row">是否删除：</th>
							    <td bgcolor="#33F2E9">
									<select name="deletechiose" id = "deletechiose">
									  <option value="0">否</option>
									  <option value="1">是</option>
								    </select>
							<script language="javascript"> 
								for(var i=0;i<document.getElementById("deletechiose").options.length;i++)
								{ 
									if(document.getElementById("deletechiose").options[i].value=='${news.deleted}')
									{ 
										document.getElementById("deletechiose").options[i].selected=true; 
									} 
								}
							</script>						      </td>
							</tr>
						</c:forEach>
						<tr>
							<th colspan="2" bgcolor="#33F2E9" scope="row">
								<div align="center">
									<p>&nbsp;									</p>
									<p>
									  <input type="submit" value="提交" name="submit"> 
									  &nbsp;
										<input type="reset" value="重置" name="reset">
									</p>
								</div>							</th>
						</tr>
				</table>
			  </form>
	  </div>
	</div>
</body>
</html>
